/*
 * 物料准备游览
 */

package org.ccams.tran;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.ccams.domain.VProduce;
import org.ccams.util.PageParameter;//用传递参数
/**
 * 物料准备交易
 * @author alern2006@163.com
 * @系统名称：定制化辅助生成制造系统
 * @时间：05 16, 2009
 */
public class Tran33990 extends AbstractJsonTran {

	@SuppressWarnings("unchecked")
	public void buildJSONObject(Map model, JSONObject json,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		int limit = Integer.parseInt(request.getParameter("limit"));
		int start = Integer.parseInt(request.getParameter("start"));
		String keyWords = (String)request.getParameter("keywords");//查询关键字
		keyWords = (keyWords != null) ? keyWords : "";		
		PageParameter page = new PageParameter();
		page.setLimit(limit);
		page.setStart(start);
		page.setKeyWords("%"+keyWords+"%");
		HashMap<String, Object> jsonMap = new HashMap<String, Object>();
		ArrayList<VProduce> al = new ArrayList<VProduce>();
		List<VProduce> list = null;
		int count = getCcamsService().getVproduceDao().getCount("%"+keyWords+"%");
		list = getCcamsService().getVproduceDao().getVProduce(page);
		for (VProduce t : list) {
			VProduce u = new VProduce();
			u.setOrgId(t.getOrgId());
			u.setDeptId(t.getDeptId());
			u.setOrderNo(t.getOrderNo());
			u.setOrdered_date(t.getOrdered_date());
			u.setOperDate(t.getOperDate()); 
			u.setIdtClient(t.getIdtClient());
			u.setUser(t.getUser());
			u.setUsertel(t.getUsertel());
			u.setUseraddress(t.getUseraddress());
			u.setOrderMoney(t.getOrderMoney());
			u.setGoodsid(t.getGoodsid());
			u.setGoodsname(t.getGoodsname());
			u.setSpec(t.getSpec());
			u.setSalePrice(t.getSalePrice());
			u.setAttrib1(t.getAttrib1());
			u.setAttrib1Unit(t.getAttrib1Unit());
			u.setAttrib2(t.getAttrib2());
			u.setAttrib2Unit(t.getAttrib2Unit());
			u.setAttrib3(t.getAttrib3());
			u.setAttrib3Unit(t.getAttrib3Unit());
			u.setAttrib4(t.getAttrib4());
			u.setAttrib4Unit(t.getAttrib4Unit());
			u.setAttrib5(t.getAttrib5());
			u.setAttrib5Unit(t.getAttrib5Unit());
			u.setProductdate(t.getProductdate());
			u.setMaterielokdate(t.getMaterielokdate());
			u.setMaterielokpid(t.getMaterielokpid());
			u.setCheckinstockpid(t.getCheckinstockpid());
			u.setCheckinstockdate(t.getCheckinstockdate());
			u.setTranfficpid(t.getTranfficpid());
			u.setSetupdate(t.getSetupdate());
			u.setSetuppid(t.getSetuppid());
			u.setTranfficdate(t.getTranfficdate());
			u.setState(t.getState());
			u.setCustomername(t.getCustomername());
			u.setIdtSalesordersH(t.getIdtSalesordersH());
			u.setLineId(t.getLineId());
			u.setIdt_salesorders_d(t.getIdt_salesorders_d());
			u.setRequest_date(t.getRequest_date());
			al.add(u);
		}
		JSONArray JsonArray = JSONArray.fromObject(al); // 得到JSON数组
		jsonMap.put("totalProperty", count);
		jsonMap.put("root", JsonArray);
		json.putAll(jsonMap);
	}
}
